package ibmetp.mis.vo;

import java.util.Date;
import java.util.List;

/**
 * @author IBMETP068
 * @version 1.0
 * @created 29-九月-2011 5:17:38
 */
public class User {

	/**
	 * 创建日期
	 */
	private Date createDate;
	/**
	 * 创建者
	 */
	private User creator;
	/**
	 * 部门
	 */
	private Dept dept;
	/**
	 * 备注
	 */
	private String descript;
	/**
	 * 电子邮件
	 */
	private String email;
	/**
	 * 用户密码
	 */
	private String pwd;
	/**
	 * 更新时间
	 */
	private Date upDate;
	/**
	 * 更新者
	 */
	private User updater;
	/**
	 * 用户ID
	 */
	private Long userId;
	/**
	 * 用户名
	 */
	private String userName;
	/**
	 * 用户编号
	 * @author BIN 
	 * @date 2011-9-30
	 */
	private String userNo;
	/**
	 * 用户资源列表
	 */
	private List<Resource> resources;
   
	public User(){

	}
   
	
	
	public List<Resource> getResources() {
		return resources;
	}



	public void setResources(List<Resource> resources) {
		this.resources = resources;
	}



	public Date getCreateDate() {
		return createDate;
	}

	public void setCreateDate(Date createDate) {
		this.createDate = createDate;
	}

	public User getCreator() {
		return creator;
	}

	public void setCreator(User creator) {
		this.creator = creator;
	}

	public Dept getDept() {
		return dept;
	}

	public void setDept(Dept dept) {
		this.dept = dept;
	}

	

	public String getDescript() {
		return descript;
	}

	public void setDescript(String descript) {
		this.descript = descript;
	}

	public String getEmail() {
		return email;
	}

	public String getPwd() {
		return pwd;
	}

	public void setPwd(String pwd) {
		this.pwd = pwd;
	}

	public Date getUpDate() {
		return upDate;
	}

	public void setUpDate(Date upDate) {
		this.upDate = upDate;
	}

	public User getUpdater() {
		return updater;
	}

	public void setUpdater(User updater) {
		this.updater = updater;
	}

	public Long getUserId() {
		return userId;
	}

	public void setUserId(Long userId) {
		this.userId = userId;
	}

	public String getUserName() {
		return userName;
	}

	public void setUserName(String userName) {
		this.userName = userName;
	}
    
	public String getUserNo() {
		return userNo;
	}

	public void setUserNo(String userNo) {
		this.userNo = userNo;
	}

	public void setEmail(String email) {
		this.email = email;
	}

	@Override
	public String toString() {
		if(resources!=null)
		for(int i=0;i<resources.size();i++)
		{  Resource r=resources.get(i);		  
			System.out.println(r.getResourceName());
		}
		return  "\nuserNo:"+userNo+" userName:"+userName ;
	}




	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((userNo == null) ? 0 : userNo.hashCode());
		return result;
	}



	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		User other = (User) obj;
		if (userNo == null) {
			if (other.userNo != null)
				return false;
		} else if (!userNo.equals(other.userNo))
			return false;
		return true;
	}

  public boolean hasResource(String url)
  {  // System.out.println(url);
      //System.out.println("----------------------------------------------");
	  for(int i=0;i<resources.size();i++)
	  {   
		 // System.out.println(resources.get(i).getUrl());
		  if(resources.get(i).getUrl()!=null&&resources.get(i).getUrl().equals(url))
			  return true;
	  }
	   //System.out.println("----------------------------------------------");
	  return false;
  }

	public void finalize() throws Throwable {

	}

}